import React from 'react'

class Home extends React.Component {

  constructor(props) {
    super(props)
    this.state = {
      count: 1
    }
    this.task = this.task.bind(this)
  }

  render() {
    return (
      <h2>{this.state.count}</h2>
    )
  }

  task () {
    this.setState({count: this.state.count + 1})
  }

  componentDidMount() {
    this.timer = setInterval(this.task, 1000)
  }
  componentWillUnmount() {
    clearInterval(this.timer)
  }
}

export default Home